<?php
/**
 *   Joomdiet - components/controllers/energeticspend.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2010 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controller');

class JoomdietControllerEnergeticSpend extends JController
{
    function __construct()
    {
        if (JRequest::getCmd('view') == '') {
            JRequest::setVar('view', 'default');
        }
        
        $this->item_type = 'Default';
        
        parent::__construct();
    }
    
    function loadactivities()
    {
        $model = $this->getModel('physicalactivity');
        
        $category_id = JRequest::getVar('category_id');
        
        $activities = $model->getPhysicalActivities($category_id);
        
        // direct response
        $response = '';
        foreach ($activities as $activity) {
            $response .= '<option value="'.$activity->id.'">'.$activity->name.'</option>';
        }
        
        echo $response;
    }
    
    function loaditem()
    {
        $view =& $this->getView('activityitem', 'raw');
        
        $view->setModel($this->getModel('physicalactivity'), 'true');
        
        $view->display();
    }
}
?>
